package main

import (
	"fmt"
)

type T1 struct {
	Name string
}

func main() {
	test6()
	//testAddr()
}

func testAddr() {
	testAddr1()
	testAddr2()
	testAddr3()
	testAddr4()
	testAddr5()
}

func testAddr1() {
	t1 := T1{}
	t2 := T1{}
	fmt.Printf("%p - %p\n", &t1, &t2)
}

func testAddr2() {
	t1 := T1{}
	t2 := t1
	fmt.Printf("%p - %p\n", &t1, &t2)
}

func testAddr3() {
	t1 := T1{}
	t2 := &t1
	fmt.Printf("%p - %p\n", &t1, &t2)
}

func testAddr4() {
	t1 := T1{}
	var t2 *T1
	t2 = &t1
	fmt.Printf("%p - %p\n", &t1, &t2)
}

func testAddr5() {
	var t1 interface{}
	t2 := T1{}
	t1 = t2
	fmt.Printf("%p,%v - %p,%v\n", &t1, t1, &t2, t2)
	t1 = &t2
	fmt.Printf("%p,%v - %p,%v\n", &t1, t1, &t2, t2)
}

type T2 struct {
	Name string
	Age  int
}

var conf = &T2{}

func init() {
	conf.Age = 10
	conf.Name = "t1"
}

func test6() {
	fmt.Printf("%p,%v \n", &conf, conf)
	newConf := *conf
	newConf.Age = 20
	fmt.Printf("%p,%v \n", &newConf, newConf)
	fmt.Printf("%p,%v \n", &conf, conf)

}
